home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
122
< prev
next >
Wrap
Text File
|
1996-08-06
|
1KB
|
39 lines
Path: lyra.csx.cam.ac.uk!nmm1
From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.std.c
Subject: Re: atexit() and return from main()
Date: 17 Jan 1996 10:17:52 GMT
Organization: University of Cambridge, England
Message-ID: <4diicg$i9e@lyra.csx.cam.ac.uk>
References: <4dhfja$j50@fg70.rz.uni-karlsruhe.de>
NNTP-Posting-Host: ursa.cus.cam.ac.uk
In article <4dhfja$j50@fg70.rz.uni-karlsruhe.de>, ig25@fg70.rz.uni-karlsruhe.de (Thomas Koenig) writes:
|> Is the following valid C? [ NMM is to blame for the style! ]
|>
|> char *a;
|> void printit() { printf("%s",a); }
|>
|> int main() {
|> char buffer[]="Hello, world!\n";
|> a = buffer;
|> atexit(printit);
|> return 0;
|> }
|>
|> 6.1.2.4 tells me it isn't, but 5.1.2.2.3 tells me that a return
|> from the initial call to main() is equivalent to an exit(), and
|> I don't see a problem when I replace the 'return 0' above with
|> an 'exit(0)'.
I do. exit() may unwind the stack before calling the atexit()
functions, and that is actually the way that most C run-time
systems implement close down.
Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email: nmm1@cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679